<template>
  <div class="app-container">
    <!-- 页面头部 -->
    <div class="page-header">
      <el-card class="header-card" shadow="never">
        <div class="header-content">
          <div class="header-left">
            <div class="header-icon">
              <el-icon><Calendar /></el-icon>
            </div>
            <div class="header-info">
              <h1>活动管理</h1>
              <p>管理社团活动发布、报名和参与情况</p>
            </div>
          </div>
          <div class="header-stats">
            <el-icon class="stats-icon"><DataBoard /></el-icon>
            <span class="stats-text">总活动数: {{ total }}</span>
          </div>
        </div>
      </el-card>
    </div>

    <!-- 搜索区域 -->
    <div class="search-container" v-show="showSearch">
      <el-card class="search-card" shadow="never">
        <el-form :model="queryParams" ref="queryRef" class="search-form">
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="活动标题" prop="title">
                <el-input
                  v-model="queryParams.title"
                  placeholder="请输入活动标题"
                  clearable
                  prefix-icon="Search"
                  @keyup.enter="handleQuery"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="活动地点" prop="location">
                <el-input
                  v-model="queryParams.location"
                  placeholder="请输入活动地点"
                  clearable
                  prefix-icon="Location"
                  @keyup.enter="handleQuery"
                />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="活动状态" prop="status">
                <el-select v-model="queryParams.status" placeholder="请选择活动状态" clearable>
                  <el-option
                    v-for="dict in activity_status"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                  />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item>
                <div class="search-buttons">
                  <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                  <el-button icon="Refresh" @click="resetQuery">重置</el-button>
                </div>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-card>
    </div>

    <!-- 操作按钮区域 -->
    <div class="action-container">
      <el-card class="action-card" shadow="never">
        <div class="action-bar">
          <div class="action-left">
            <el-button
              type="primary"
              icon="Plus"
              @click="handleAdd"
              v-hasPermi="['system:activities:add']"
              class="action-btn primary-btn"
            >
              <span>发布活动</span>
            </el-button>
            <el-button
              type="success"
              icon="Edit"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['system:activities:edit']"
              class="action-btn"
            >
              <span>修改</span>
            </el-button>
            <el-button
              type="danger"
              icon="Delete"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['system:activities:remove']"
              class="action-btn"
            >
              <span>批量删除</span>
            </el-button>
            <el-button
              type="warning"
              icon="Download"
              @click="handleExport"
              v-hasPermi="['system:activities:export']"
              class="action-btn"
            >
              <span>导出数据</span>
            </el-button>
          </div>
          <div class="action-right">
            <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
          </div>
        </div>
      </el-card>
    </div>

    <!-- 活动列表 -->
    <div class="table-container">
      <el-card class="table-card" shadow="never">
        <el-table 
          v-loading="loading" 
          :data="activitiesList" 
          @selection-change="handleSelectionChange"
          class="activities-table"
          :header-cell-style="{ background: '#f8f9fa', color: '#606266', fontWeight: '600' }"
        >
          <el-table-column type="selection" width="55" align="center" />
          
          <!-- 活动信息 -->
          <el-table-column label="活动信息" align="left" min-width="250">
            <template #default="scope">
              <div class="activity-info">
                <div class="activity-header">
                  <div class="activity-title">{{ scope.row.title }}</div>
                </div>
                <div class="activity-location">
                  <el-icon class="location-icon"><Location /></el-icon>
                  <span>{{ scope.row.location }}</span>
                </div>
              </div>
            </template>
          </el-table-column>
          
          <!-- 时间信息 -->
          <el-table-column label="活动时间" align="center" min-width="200">
            <template #default="scope">
              <div class="time-info">
                <div class="time-item start-time">
                  <el-icon class="time-icon"><Timer /></el-icon>
                  <div class="time-details">
                    <span class="time-label">开始:</span>
                    <span class="time-value">{{ parseTime(scope.row.startTime, '{y}-{m}-{d} {h}:{i}') }}</span>
                  </div>
                </div>
                <div class="time-item end-time">
                  <el-icon class="time-icon"><Clock /></el-icon>
                  <div class="time-details">
                    <span class="time-label">结束:</span>
                    <span class="time-value">{{ parseTime(scope.row.endTime, '{y}-{m}-{d} {h}:{i}') }}</span>
                  </div>
                </div>
              </div>
            </template>
          </el-table-column>
          
          <!-- 参与情况 -->
          <el-table-column label="参与情况" align="center" min-width="120">
            <template #default="scope">
              <div class="participation-info">
                <div class="participant-count">
                  <el-icon class="count-icon"><User /></el-icon>
                  <span class="count-text">{{ (scope.row.currentParticipants || 0) }}/{{ scope.row.maxParticipants || 0 }}</span>
                </div>
                <el-progress 
                  :percentage="Math.round(((scope.row.currentParticipants || 0) / (scope.row.maxParticipants || 1)) * 100)"
                  :stroke-width="6"
                  :show-text="false"
                  :color="getProgressColor((scope.row.currentParticipants || 0) / (scope.row.maxParticipants || 1))"
                />
              </div>
            </template>
          </el-table-column>
          
          <!-- 状态信息 -->
          <el-table-column label="状态信息" align="center" min-width="150">
            <template #default="scope">
              <div class="status-info">
                <div class="activity-status">
                  <dict-tag :options="activity_status" :value="scope.row.status"/>
                </div>
                <div class="registration-status">
                  <el-tag 
                    v-if="scope.row.participated" 
                    type="success" 
                    effect="light"
                    class="status-tag"
                  >
                    <el-icon><Check /></el-icon>
                    <span>已报名</span>
                  </el-tag>
                  <el-tag 
                    v-else-if="(scope.row.currentParticipants || 0) >= (scope.row.maxParticipants || 0)" 
                    type="danger" 
                    effect="light"
                    class="status-tag"
                  >
                    <el-icon><Close /></el-icon>
                    <span>已满员</span>
                  </el-tag>
                  <el-tag 
                    v-else 
                    type="warning" 
                    effect="light"
                    class="status-tag"
                  >
                    <el-icon><Clock /></el-icon>
                    <span>可报名</span>
                  </el-tag>
                </div>
              </div>
            </template>
          </el-table-column>
          
          <!-- 操作列 -->
          <el-table-column label="操作" align="center" width="200" fixed="right">
            <template #default="scope">
              <div class="action-buttons">
                <el-button 
                  type="info" 
                  size="small" 
                  icon="View" 
                  @click="handleView(scope.row)" 
                  class="action-btn-small"
                >
                  查看
                </el-button>
                <el-button 
                  v-if="!scope.row.participated && scope.row.status === 1 && (scope.row.currentParticipants || 0) < (scope.row.maxParticipants || 0)"
                  type="success" 
                  size="small" 
                  icon="Plus" 
                  @click="handleJoin(scope.row)"
                  class="action-btn-small join-btn"
                >
                  报名
                </el-button>
                <el-button 
                  v-if="scope.row.participated && scope.row.status === 1"
                  type="warning" 
                  size="small" 
                  icon="Minus" 
                  @click="handleQuit(scope.row)"
                  class="action-btn-small quit-btn"
                >
                  取消报名
                </el-button>
                <el-button 
                  type="primary" 
                  size="small" 
                  icon="Edit" 
                  @click="handleUpdate(scope.row)" 
                  v-hasPermi="['system:activities:edit']"
                  class="action-btn-small"
                >
                  修改
                </el-button>
                <el-button 
                  type="danger" 
                  size="small" 
                  icon="Delete" 
                  @click="handleDelete(scope.row)" 
                  v-hasPermi="['system:activities:remove']"
                  class="action-btn-small"
                >
                  删除
                </el-button>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
    </div>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改活动对话框 -->
    <el-dialog :title="title" v-model="open" width="600px" append-to-body>
      <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
        <el-form-item label="活动标题" prop="title">
          <el-input v-model="form.title" placeholder="请输入活动标题" />
        </el-form-item>
        <el-form-item label="选择社团" prop="clubName">
          <el-select v-model="form.clubId" placeholder="请选择社团" style="width: 100%" @change="handleClubChange">
            <el-option
                v-for="club in userClubs"
                :key="club.clubId"
                :label="club.name"
                :value="club.clubId"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="活动内容" prop="content">
          <el-input
            type="textarea"
            placeholder="请输入内容"
            v-model="form.content"
            maxlength="200"
            show-word-limit
          >
          </el-input>
        </el-form-item>
        <el-form-item label="活动地点" prop="location">
          <el-input v-model="form.location" placeholder="请输入活动地点" />
        </el-form-item>
        <el-row>
          <el-col :span="12">
            <el-form-item label="开始时间" prop="startTime">
              <el-date-picker
                v-model="form.startTime"
                type="datetime"
                value-format="YYYY-MM-DD HH:mm:ss"
                placeholder="请选择开始时间"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结束时间" prop="endTime">
              <el-date-picker
                v-model="form.endTime"
                type="datetime"
                value-format="YYYY-MM-DD HH:mm:ss"
                placeholder="请选择结束时间"
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="最大参与人数" prop="maxParticipants">
          <el-input-number v-model="form.maxParticipants" :min="1" :max="1000" placeholder="请输入" style="width: 100%" />
        </el-form-item>
        <el-form-item label="活动状态" prop="status">
          <el-select v-model="form.status" placeholder="请选择状态" style="width: 100%">
            <el-option
              v-for="dict in activity_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 活动详情对话框 -->
    <el-dialog title="活动详情" v-model="viewOpen" width="800px" append-to-body>
      <div v-if="viewForm">
        <el-descriptions :column="2" border>
          <el-descriptions-item label="活动标题">{{ viewForm.title }}</el-descriptions-item>
          <el-descriptions-item label="活动地点">{{ viewForm.location }}</el-descriptions-item>
          <el-descriptions-item label="开始时间">{{ parseTime(viewForm.startTime, '{y}-{m}-{d} {h}:{i}') }}</el-descriptions-item>
          <el-descriptions-item label="结束时间">{{ parseTime(viewForm.endTime, '{y}-{m}-{d} {h}:{i}') }}</el-descriptions-item>
          <el-descriptions-item label="参与人数">{{ (viewForm.currentParticipants || 0) }}/{{ viewForm.maxParticipants || 0 }}</el-descriptions-item>
          <el-descriptions-item label="活动状态">
            <dict-tag :options="activity_status" :value="viewForm.status" />
          </el-descriptions-item>
        </el-descriptions>
        
        <el-divider content-position="left">活动内容</el-divider>
        <div class="activity-content" v-html="viewForm.content"></div>
        
        <el-divider content-position="left">报名情况</el-divider>
        <el-table :data="participantsList" style="width: 100%">
          <el-table-column prop="nickName" label="参与者" width="120">
            <template #default="scope">
              <span>{{ scope.row.nickName || scope.row.userName }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="phonenumber" label="联系电话" width="120" />
          <el-table-column prop="joinTime" label="报名时间" width="180">
            <template #default="scope">
              <span>{{ parseTime(scope.row.joinTime, '{y}-{m}-{d} {h}:{i}') }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="status" label="状态" width="100">
            <template #default="scope">
              <el-tag :type="scope.row.status === 1 ? 'success' : 'info'">
                {{ scope.row.status === 1 ? '已确认' : '待确认' }}
              </el-tag>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="viewOpen = false">关 闭</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Activities">
import { ref, reactive, toRefs, getCurrentInstance, onMounted } from 'vue'
import { Calendar, DataBoard, Location, Timer, Clock, User, Check, Close } from '@element-plus/icons-vue'
import { listActivities, getActivities, delActivities, addActivities, updateActivities } from "@/api/system/activities"
import { selectUserClubs } from "@/api/system/clubs"
import { listParticipants, listParticipantsWithUser, addParticipants, delParticipants } from "@/api/system/participants"

const { proxy } = getCurrentInstance();
const { activity_status } = proxy.useDict("activity_status");
const userClubs = ref([]);
const activitiesList = ref([]);
const participantsList = ref([]);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const open = ref(false);
const viewOpen = ref(false);
const title = ref("");
const viewForm = ref({});

const data = reactive({
  form: {
    activityId: undefined,
    clubId: undefined,
    title: undefined,
    content: undefined,
    location: undefined,
    startTime: undefined,
    endTime: undefined,
    maxParticipants: 50,
    status: "1"
  },
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    title: undefined,
    location: undefined,
    status: undefined
  },
  rules: {
    title: [{ required: true, message: "活动标题不能为空", trigger: "blur" }],
    content: [{ required: true, message: "活动内容不能为空", trigger: "blur" }],
    location: [{ required: true, message: "活动地点不能为空", trigger: "blur" }],
    startTime: [{ required: true, message: "开始时间不能为空", trigger: "blur" }],
    endTime: [{ required: true, message: "结束时间不能为空", trigger: "blur" }],
    maxParticipants: [{ required: true, message: "最大参与人数不能为空", trigger: "blur" }],
    status: [{ required: true, message: "活动状态不能为空", trigger: "change" }]
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询活动列表 */
function getList() {
  loading.value = true;
  listActivities(queryParams.value).then(response => {
    activitiesList.value = response.rows || [];
    total.value = response.total || 0;
    // 检查用户报名状态
    checkParticipationStatus();
    loading.value = false;
  }).catch(error => {
    console.error('获取活动列表失败:', error);
    loading.value = false;
  });
}

/** 检查用户报名状态 */
function checkParticipationStatus() {
  // 遍历活动列表，检查当前用户是否已报名每个活动
  activitiesList.value.forEach(activity => {
    // 确保数据初始化
    activity.participated = activity.participated || false;
    activity.currentParticipants = activity.currentParticipants || 0;
    activity.maxParticipants = activity.maxParticipants || 0;
  });
}

/** 社团选择变化 */
function handleClubChange(row) {
  // 可以在这里添加社团相关的逻辑
  console.info(row)
  
}

/** 取消按钮 */
function cancel() {
  open.value = false;
  reset();
}

/** 表单重置 */
function reset() {
  form.value = {
    activityId: undefined,
    clubId: undefined,
    title: undefined,
    content: undefined,
    location: undefined,
    startTime: undefined,
    endTime: undefined,
    maxParticipants: 50,
    status: "1"
  };
  proxy.resetForm("formRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

/** 多选框选中数据 */
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.activityId);
  single.value = selection.length !== 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  getUserClubs();
  title.value = "发布新活动";
}

/** 获取用户可发帖的社团列表 */
function getUserClubs() {
  selectUserClubs().then(response => {
    userClubs.value = response.rows || [];
  }).catch(error => {
    console.error('获取用户社团列表失败:', error);
    userClubs.value = [];
  });
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
   getUserClubs();
  const activityId = row.activityId || ids.value[0];
  getActivities(activityId).then(response => {
    form.value = response.data;
    open.value = true;
    title.value = "修改活动信息";
  }).catch(error => {
    console.error('获取活动详情失败:', error);
    proxy.$modal.msgError("获取活动详情失败");
  });
}

/** 查看按钮操作 */
function handleView(row) {
  getActivities(row.activityId).then(response => {
    viewForm.value = response.data || {};
    viewOpen.value = true;
    getParticipantsList(row.activityId);
  }).catch(error => {
    console.error('获取活动详情失败:', error);
    proxy.$modal.msgError("获取活动详情失败");
  });
}

/** 获取报名列表 */
function getParticipantsList(activityId) {
  listParticipantsWithUser({ activityId: activityId }).then(response => {
    participantsList.value = response.rows || [];
  }).catch(error => {
    console.error('获取报名列表失败:', error);
    participantsList.value = [];
  });
}

/** 参加活动 */
function handleJoin(row) {
  proxy.$modal.confirm('确认报名参加"' + row.title + '"活动吗？').then(() => {
    const participantData = {
      activityId: row.activityId,
      status: "1" // 待确认状态
    };
    addParticipants(participantData).then(response => {
      proxy.$modal.msgSuccess("报名成功");
      // 重新检查该活动的报名状态
      row.participated = true;
      checkActivityParticipationStatus(row.activityId);
    }).catch(error => {
      proxy.$modal.msgError("报名失败：" + (error.message || '未知错误'));
    });
  });
}

/** 取消参加活动 */
function handleQuit(row) {
  proxy.$modal.confirm('确认取消报名"' + row.title + '"活动吗？').then(() => {
    // 先查询用户的报名记录ID，然后删除
    listParticipantsWithUser({ 
      activityId: row.activityId, 
    }).then(response => {
      if (response.rows && response.rows.length > 0) {
        const participantId = response.rows[0].id;
        return delParticipants(participantId);
      } else {
        throw new Error('未找到报名记录');
      }
    }).then(() => {
      proxy.$modal.msgSuccess("取消报名成功");
      row.participated = false;
      // 重新检查该活动的报名状态
      checkActivityParticipationStatus(row.activityId);
    }).catch(error => {
      proxy.$modal.msgError("取消报名失败：" + (error.message || '未知错误'));
    });
  });
}

/** 提交表单 */
function submitForm() {
  proxy.$refs["formRef"].validate(valid => {
    if (valid) {
      if (form.value.activityId !== undefined) {
        updateActivities(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        }).catch(error => {
          proxy.$modal.msgError("修改失败：" + (error.message || '未知错误'));
        });
      } else {
        addActivities(form.value).then(response => {
          proxy.$modal.msgSuccess("发布成功");
          open.value = false;
          getList();
        }).catch(error => {
          proxy.$modal.msgError("发布失败：" + (error.message || '未知错误'));
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const activityIds = row.activityId || ids.value;
  proxy.$modal.confirm('是否确认删除活动ID为"' + activityIds + '"的数据项？').then(function() {
    return delActivities(activityIds);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download("system/activities/export", {
    ...queryParams.value
  }, `activities_${new Date().getTime()}.xlsx`);
}

/** 检查特定活动的报名状态 */
function checkActivityParticipationStatus(activityId) {
  // 调用后端接口检查当前用户是否已报名该活动
  listParticipantsWithUser({ 
    activityId: activityId, 
  }).then(response => {
    // 更新活动列表中的报名状态
    const activity = activitiesList.value.find(item => item.activityId === activityId);
    if (activity) {
      activity.participated = response.rows && response.rows.length > 0;
      activity.currentParticipants = response.rows ? response.rows.length : 0;
    }
  }).catch(error => {
    console.error('检查报名状态失败:', error);
  });
}

/** 获取进度条颜色 */
function getProgressColor(percentage) {
  if (percentage < 0.5) {
    return '#67c23a';
  } else if (percentage < 0.8) {
    return '#e6a23c';
  } else {
    return '#f56c6c';
  }
}

// 组件挂载时初始化数据
onMounted(() => {
  getList();
});
</script>

<style scoped>
.app-container {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: 100vh;
}

/* 页面头部样式 */
.page-header {
  margin-bottom: 20px;
}

.header-card {
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-icon {
  width: 60px;
  height: 60px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.header-info h1 {
  margin: 0 0 5px 0;
  font-size: 28px;
  font-weight: 600;
}

.header-info p {
  margin: 0;
  opacity: 0.9;
  font-size: 14px;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.1);
  padding: 10px 20px;
  border-radius: 25px;
  backdrop-filter: blur(10px);
}

.stats-icon {
  font-size: 18px;
}

.stats-text {
  font-size: 16px;
  font-weight: 500;
}

/* 搜索区域样式 */
.search-container {
  margin-bottom: 20px;
}

.search-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.search-form {
  padding: 10px 0;
}

.search-buttons {
  display: flex;
  gap: 10px;
}

/* 操作区域样式 */
.action-container {
  margin-bottom: 20px;
}

.action-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
}

.action-left {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.action-btn {
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.primary-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* 表格容器样式 */
.table-container {
  margin-bottom: 20px;
}

.table-card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.activities-table {
  border-radius: 12px;
  overflow: hidden;
}

/* 活动信息样式 */
.activity-info {
  text-align: left;
  padding: 8px 0;
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.activity-title {
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  cursor: pointer;
  transition: color 0.3s ease;
}

.activity-title:hover {
  color: #409eff;
}

.activity-id {
  font-size: 12px;
  color: #909399;
  background: #f0f2f5;
  padding: 2px 8px;
  border-radius: 12px;
}

.activity-location {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #606266;
  font-size: 14px;
}

.location-icon {
  color: #409eff;
  font-size: 14px;
}

/* 时间信息样式 */
.time-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.time-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  background: #f8f9fa;
}

.start-time {
  border-left: 3px solid #67c23a;
}

.end-time {
  border-left: 3px solid #e6a23c;
}

.time-icon {
  font-size: 14px;
  color: #606266;
}

.time-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.time-label {
  font-size: 12px;
  color: #909399;
  font-weight: 500;
}

.time-value {
  font-size: 13px;
  color: #303133;
  font-weight: 500;
}

/* 参与情况样式 */
.participation-info {
  padding: 8px 0;
}

.participant-count {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.count-icon {
  color: #409eff;
  font-size: 16px;
}

.count-text {
  font-size: 14px;
  font-weight: 600;
  color: #303133;
}

/* 状态信息样式 */
.status-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
}

.activity-status {
  display: flex;
  justify-content: center;
}

.registration-status {
  display: flex;
  justify-content: center;
}

.status-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
}

/* 操作按钮样式 */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 8px 0;
}

.action-btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.3s ease;
}

.action-btn-small:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.join-btn {
  background: linear-gradient(135deg, #67c23a 0%, #85ce61 100%);
  border: none;
  color: white;
}

.quit-btn {
  background: linear-gradient(135deg, #e6a23c 0%, #f0a020 100%);
  border: none;
  color: white;
}

/* 活动详情样式 */
.activity-content {
  padding: 20px;
  background-color: #f8f9fa;
  border-radius: 8px;
  min-height: 100px;
  line-height: 1.6;
  border: 1px solid #e4e7ed;
}

.el-descriptions {
  margin-bottom: 20px;
}

.el-divider {
  margin: 20px 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .app-container {
    padding: 10px;
  }
  
  .header-content {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
  
  .action-left {
    justify-content: center;
  }
  
  .action-bar {
    flex-direction: column;
    gap: 15px;
  }
  
  .time-info {
    gap: 6px;
  }
  
  .time-item {
    padding: 4px 8px;
  }
  
  .action-buttons {
    flex-direction: column;
  }
}

/* 表格行悬停效果 */
.activities-table :deep(.el-table__row:hover) {
  background-color: #f8f9fa !important;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

/* 表格头部样式 */
.activities-table :deep(.el-table__header-wrapper) {
  border-radius: 12px 12px 0 0;
}

/* 分页样式 */
:deep(.el-pagination) {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}
</style>